-
Notifications
You must be signed in to change notification settings - Fork 134
fix(pb): simplify runner wf #3483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 11-18-fix_gas_fix_loop_forgotten_bug_due_to_concurrency
Are you sure you want to change the base?
fix(pb): simplify runner wf #3483
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
More templates
@rivetkit/cloudflare-workers
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
Pull Request ReviewOverviewThis PR simplifies the runner workflow by removing the command/event handling logic from the runner workflow and moving event forwarding directly to actor workflows. This is a significant refactoring that reduces ~500 lines of code by eliminating intermediate state management. Key Changes
Code Quality & Best Practices✅ Good:
Potential Bugs❌ CRITICAL: Compilation Error
Performance Considerations✅ Improvements:
Security Concerns✅ No new security issues introduced
Test Coverage
Additional Questions
SummaryThis is a valuable simplification that removes significant complexity from the runner workflow. However, there's a critical compilation error that needs to be fixed before this can be merged. Additionally, the missing event acknowledgment logic needs to be clarified or implemented. Recommendation: Request changes to fix the compilation error and clarify the event acknowledgment and command flow architecture. Review generated following CLAUDE.md conventions for error handling, logging patterns, and code style. |
fa56065 to
fefb6f0
Compare
1a4f15a to
4294775
Compare
Code ReviewOverviewThis PR significantly simplifies the runner workflow by removing event and command tracking logic. The changes reduce the workflow state and delegate more responsibility to actor workflows. Key Changes Analysis1. Removed Event/Command State Management ✅The PR removes:
Positive: This is a good simplification that reduces state size and complexity. 2. Event Forwarding Moved to WebSocket Handler ✅In protocol::ToServer::ToServerEvents(events) => {
let res = ctx.signal(pegboard::workflows::runner2::Forward {
inner: protocol::ToServer::try_from(msg)
.context("failed to convert message for workflow forwarding")?,
})
.tag("actor_id", actor_id)
.graceful_not_found()
// ...
}Issue Found: This code references Looking at the protocol, Recommendation: You need to iterate over the events and extract actor_id properly: protocol::ToServer::ToServerEvents(events) => {
for event in &events.events {
let actor_id = crate::utils::event_actor_id(&event.inner);
let res = ctx.signal(pegboard::workflows::actor::Event {
inner: event.inner.clone(),
})
.to_workflow::<pegboard::workflows::actor::Workflow>()
.tag("actor_id", &actor_id.to_string())
.graceful_not_found()
.send()
.await
.with_context(|| {
format!("failed to forward signal to actor workflow: {}", actor_id)
})?;
if res.is_none() {
tracing::warn!(?actor_id, "failed to send signal to actor workflow, likely already stopped");
}
}
}3. Removed Init Message Handling 🔍The runner workflow no longer processes
Concerns:
Recommendation: Verify that runner initialization is complete elsewhere, or this may break runner connectivity and actor allocation. 4. Simplified Runner Workflow State ✅
struct LifecycleState {
draining: bool,
}Positive: Much cleaner state management. 5. Variable Naming Improvement ✅In 6. Removed Signal Type ✅Removed Potential Issues
Testing Recommendations
Security ConsiderationsNo security issues identified. The changes maintain proper actor ownership validation in KV operations. Performance ConsiderationsPositive: Removing state buffering reduces memory usage and workflow replay time. The simplified state should improve workflow performance. Code Quality
SummaryThis is a good architectural simplification, but has critical compilation errors that must be fixed before merging. The undefined Recommendation: Fix the compilation error, verify the init flow is complete, and add tests before merging. |
|
Critical Bug Found: The variable |
|
PR Review Summary - Part 1: This PR significantly simplifies the runner workflow by removing ~500 lines of code. Major changes include: MUST FIX:
CODE QUALITY ISSUES:
ARCHITECTURAL CONCERNS:
Questions to address:
|
|
PR Review Summary - Part 2: PERFORMANCE CONSIDERATIONS: Positive:
Concerns:
TEST COVERAGE:
POSITIVE CHANGES:
Overall: This is a valuable simplification but needs the compilation fix and testing before merge. The architectural changes need documentation to help understand the new event flow and migration path for existing runners. |
fefb6f0 to
c088d42
Compare
4294775 to
5458e50
Compare
Code ReviewI've reviewed this PR which simplifies the runner workflow. Here's my detailed feedback: 🎯 Overall AssessmentThis is a substantial refactoring that introduces a new protocol version (v4/mk2) and simplifies the runner workflow architecture. The changes are generally well-structured, but there are several areas that need attention. ✅ Strengths
🔴 Critical Issues1. Compilation Errors in tunnel_to_ws_task.rsThe refactored code has critical issues that will prevent compilation: Lines ~45-65: The
The functions appear to have been extracted but weren't properly parameterized. Example: async fn recv_msg() -> Result<std::result::Result<Option<()>, LifecycleResult>> {
let tunnel_msg = tokio::select! {
res = tunnel_sub.next() => { // ❌ tunnel_sub not in scopeFix: Add proper parameters to these functions or inline them back into the main task loop. 2. Missing Signal Type in conn.rs:149ctx.signal(Init); // ❌ What is Init?This signal type doesn't appear to be defined anywhere in the visible code. This will fail to compile. 3. Undefined Helper Function in lib.rsLine 6 references let workflow_id = if protocol::is_new(protocol_version) { // ❌ Undefined functionShould probably be 4. Incorrect Return Type in tunnel_to_ws_task.rsasync fn recv_msg() -> Result<std::result::Result<Option<()>, LifecycleResult>> {
// ...
Ok(Some(data)) // ❌ Returns data but signature says Option<()>
}The function signature says it returns
|
PR Review: fix(pb): simplify runner wfI've reviewed this PR which introduces a new protocol version (v4/mk2) for the pegboard runner workflow and adds an event demuxer for actor events. Critical Issues1. Compilation Errors in tunnel_to_ws_task.rs
These helper functions need to either accept the necessary parameters in their signatures OR be moved inside the main function as closures. 2. Compilation Errors in ws_to_tunnel_task.rs 3. Missing Signal Handling in conn.rs High Priority Issues4. Potential Memory Leak in ActorEventDemuxer 5. Error Handling Silently Drops Send Failures 6. Protocol Version Checking Inconsistencies Medium Priority Issues7. Missing Protocol Version Field 8. Incorrect Message Type Usage Code QualityGood:
Suggestions:
SummaryCannot merge as-is due to compilation errors. Priority fixes:
Once addressed, this is a solid simplification! |
c088d42 to
657b813
Compare
5458e50 to
8431b53
Compare
PR Review: fix(pb): simplify runner wfSummaryThis PR introduces a new protocol version (mk2/v4) for the pegboard runner workflow while maintaining backwards compatibility with the existing mk1 protocol. The goal appears to be simplifying the runner workflow architecture by moving certain processing logic from the workflow to the WebSocket task handlers. 🔴 Critical Issues - Code Won't CompileThe PR has several critical compilation errors that must be fixed before merging: 1. Functions with missing/incorrect parameters (
|
| File | Priority | Issue |
|---|---|---|
tunnel_to_ws_task.rs |
🔴 Critical | Won't compile - function scoping issues |
ws_to_tunnel_task.rs |
🔴 Critical | Won't compile - undefined variables, wrong types |
conn.rs |
🔴 Critical | Undefined Init signal, wrong function name |
actor_event_demuxer.rs |
🟡 Medium | Logic bug with last_seen |
runner2.rs |
🟢 Low | Missing protocol_version in InsertDbInput |
🤖 Generated with Claude Code
Code Review: fix(pb): simplify runner wfSummaryThis PR introduces a significant refactoring of the Pegboard runner workflow system, adding a "mk2" protocol version (v4) while maintaining backward compatibility with mk1 (v1-v3). The changes simplify the runner workflow by moving more event handling logic from the workflow itself to the WebSocket task layer. Critical Issues1. Compilation Errors - Code Will Not BuildMultiple files have severe issues that will prevent compilation:
2. Missing Import -
|
8431b53 to
5972ed8
Compare
657b813 to
bc2bb7c
Compare
PR Review: fix(pb): simplify runner wfThis PR introduces significant architectural changes to the Pegboard runner workflow, including a new protocol version ("mk2") and refactoring of the connection handling and event dispatching. Here's my detailed review: 🔴 Critical Issues1. Compilation Errors - Missing Variables in ScopeSeveral functions reference variables that are not in scope, indicating the code is incomplete or won't compile:
2. Incomplete Implementation
3. Missing Signal Struct
🟡 Potential Bugs1. ActorEventDemuxer - Event Loss on First IngestIn pub fn ingest(&mut self, actor_id: Id, event: protocol::Event) {
if let Some(channel) = self.channels.get(&actor_id) {
let _ = channel.tx.send(event); // Existing channel - event sent
} else {
// New channel created... but `event` is never sent!
let (tx, mut rx) = mpsc::unbounded_channel();
// ...
self.channels.insert(actor_id, Channel { tx, handle, last_seen: Instant::now() });
}
// ... gc code
}The first event for each actor will be dropped. 2. GC Never Updates
|
PR Review: fix(pb): simplify runner wfSummaryThis PR introduces significant changes to the Pegboard runner system, introducing a new protocol version (v4/mk2) alongside maintaining backwards compatibility with v1-v3 (mk1). The main goal appears to be simplifying the runner workflow by moving more logic into the pegboard-runner service rather than the workflow itself. Critical Issues1. Compilation Errors - Missing Variables in ClosuresSeveral functions in tunnel_to_ws_task.rs:52-77 - async fn recv_msg() -> Result<std::result::Result<(), LifecycleResult>> {
let tunnel_msg = tokio::select! {
res = tunnel_sub.next() => { // tunnel_sub not in scopetunnel_to_ws_task.rs:80-163 - async fn handle_message_mk2() -> Result<()> {
// Parse message
let msg = match versioned::ToRunner2::deserialize_with_embedded_version(&tunnel_msg.payload) {
// tunnel_msg not in scope, ctx not in scopews_to_tunnel_task.rs:79-117 - Same issue with ws_to_tunnel_task.rs:119-464 - ws_to_tunnel_task.rs:467-759 - 2. Incomplete Function Bodyws_to_tunnel_task.rs:761-768 - async fn ack_commands(ctx: &StandaloneCtx) -> Result<()> {
// ctx.udb()?.run(|| {
// let last_ack = ;
// let stream = .read_ranges_keyvalues({
// limit:
// });
// }).await?;
}This function is called but does nothing and doesn't return properly. 3. Missing Signal Definitionconn.rs:177-178 - if protocol::is_new(protocol_version) {
ctx.signal(Init); // Init is not defined anywhere visible4. Use of
|

No description provided.